﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using iLangl.LanguageWire.DAL.LanguageWireDAL.MockupStorage;
using iLangl.LanguageWire.DAL.LanguageWireDAL.RealStorage;

namespace iLangl.LanguageWire.DAL.LanguageWireDAL
{
	public class DALFacadeLW : IDALFacadeLW
	{
		#region Singelton
		IDALFacadeLW _dalfacade;
		private DALFacadeLW(IDALFacadeLW dalfacade)
		{
			_dalfacade = dalfacade;
		}

		private static DALFacadeLW instance;
		private static object mutex = new object();
		/// <summary>
		/// The instance of the DALFacade.
		/// </summary>
		public static DALFacadeLW Instance
		{
			get
			{
				if (instance == null)
				{
					lock (mutex)
					{
						if (instance == null)
						{
							IDALFacadeLW dalfacade = null;

							if (DALFacadeConfigurationLW.Instance.StorageType == "MOCKUP")
							{
								dalfacade = new MockupDALFacade();
							}
							else
							{
								dalfacade = new DALFacadeLWAPI();
							}

							instance = new DALFacadeLW(dalfacade);
						}
					}
				}
				return instance;
			}
		}

		#endregion

		public ISettingsDAL SettingsDAL
		{
			get { return _dalfacade.SettingsDAL; }
		}
		
		public ICompanyDAL CompanyDAL
		{
			get { return _dalfacade.CompanyDAL; }
		}
		
		public IProjectDAL ProjectDAL
		{
			get { return _dalfacade.ProjectDAL; }
		}
		
		public IContactDAL ContactDAL
		{
			get { return _dalfacade.ContactDAL; }
		}

		public IInvoiceDAL InvoiceDAL
		{
			get { return _dalfacade.InvoiceDAL; }
		}

		public ISynchronizationDAL SynchronizationDAL
		{
			get { return _dalfacade.SynchronizationDAL; }
		}
	}
}
